package org.springblade.modules.personal.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.vo.UserVO;
import org.springblade.modules.system.wrapper.UserWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 基本用户字段 控制器
 *
 * @author junxin
 * @since 2023-03-22
 */
@RestController
@AllArgsConstructor
@RequestMapping("personal")
@Api(value = "个人中心", tags = "个人中心字段接口")
public class PersonalController extends BladeController {

	private final IUserService userService;

	/**
	 * 个人信息 查询单条
	 */
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "个人基本信息", notes = "传入id")
	@GetMapping("/info")
	public R<UserVO> personalInfo(User user) {
		User detail = userService.getOne(Condition.getQueryWrapper(user));
		return R.data(UserWrapper.build().entityVO(detail));
	}

}
